/**
 * 20211215:抽离出检测函数getIntersects
  * 20220304:[require] to [import]...jordia
 */
import DragMeshConfig from "./drag-mesh-config";
import {Object3D} from 'three';

/**
 * 3D物体中心（threshold为半径）拖动配置
 */
export default class DragCenterConfig extends DragMeshConfig{
    constructor(values){
        super(values);
    }
    get type(){
        return 'dragCenterConfig';
    }
    checkType(object) {
        return object instanceof Object3D;
    }

    getIntersects(object,out=[]){
        object.getWorldPosition(this._tV0);
        let dsq=this._raycaster.ray.distanceSqToPoint(this._tV0);
        if(dsq>this._threshold*this._threshold)return out;
        out.push({point:this._tV0.clone(),object:object,distance:Math.sqrt(dsq)});
        return out;
    }

}